#ifndef									__QTASYNCUDPSOCKET_H__
#	define								__QTASYNCUDPSOCKET_H__

#	include								<QtNetwork/QUdpSocket>
#	include								<qobject.h>
#	include								"AAsyncTcpSocket.h"
#	include								"byte.h"
#	include								"Processor.h"

class									QtAsyncUdpSocket : public QObject, AAsyncTcpSocket
{
	Q_OBJECT

public:
	QtAsyncUdpSocket(Processor &);
	virtual ~QtAsyncUdpSocket();

public:
	virtual void						connectToHost(const std::string &, const std::string &);
	virtual void						init();
	virtual size_t						write(byte*, size_t);
	virtual	void						sendOrder(IOrder*);
	virtual	void						close();
	virtual std::string					getIp();

private:
	Processor							&_proc;
	QUdpSocket							_socket;
	byte								_tmp_buf[4096];
	unsigned short						_current_msg;
	unsigned short						_id;

private:
	void								onReceive(size_t);
	void								getOrderSize();

	private slots:
	void								handle_read();

};

#endif									// !__QTASYNCUDPSOCKET_H__
